package org.seven.jrdp.biz.t.service;

import java.util.List;

import org.seven.jrdp.biz.t.mapper.TWlMapper;
import org.seven.jrdp.biz.t.model.TWl;
import org.seven.jrdp.commons.model.Option;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria;

@Service
public class TWlService {
	@Autowired
	private TWlMapper tWlMapper;

	@Transactional(readOnly = true)
	public List<TWl> find() {
		Example example = new Example(TWl.class);
		example.orderBy("mc");
		Criteria criteria = example.createCriteria();
		criteria.andEqualTo("deleteFlag", "0");
		return tWlMapper.selectByExample(example);
	}

	@Transactional(readOnly = true)
	public TWl get(String id) {
		return tWlMapper.selectByPrimaryKey(id);
	}

	@Transactional
	public void insert(TWl tWl) {
		tWlMapper.insertSelective(tWl);
	}

	@Transactional
	public void update(TWl tWl) {
		tWlMapper.updateByPrimaryKeySelective(tWl);
	}

	@Transactional
	public void delete(String id) {
		TWl tWl = new TWl();
		tWl.setId(id);
		tWl.setDeleteFlag("1");
		tWlMapper.updateByPrimaryKeySelective(tWl);
	}

	@Transactional(readOnly = true)
	public List<Option> getOption() {
		return tWlMapper.getOption();
	}
}